package com.tau.iplayer.client;

import java.util.Date;

public class IPlayerUtils {

	private static final String YOUTUBE_PREFIX = "http://www.youtube.com/v/";

	public static String formatTime(int seconds) {
		int minutes = seconds / 60;
		seconds = seconds % 60;
		String minutesStr = String.valueOf(minutes);
		String secondsStr = String.valueOf(seconds);
		while (minutesStr.length() < 2) {
			minutesStr = "0" + minutesStr;
		}
		while (secondsStr.length() < 2) {
			secondsStr = "0" + secondsStr;
		}
		String time = minutesStr + ":" + secondsStr;
		return time;
	}

	public static String getYouTubeURL(String id) {
		return YOUTUBE_PREFIX + id;
	}
	
	public static String formatDate(Date date) {
		String rawDateStr = date.toString();
		String[] strings = rawDateStr.split(" ");
		return(strings[1] + " " + strings[2] + " " +strings[5]);
	}

	public static boolean isEmpty(String string) {
		return(string == null || string.length() == 0);
	}

}
